#define  _CRT_SECURE_NO_WARNINGS 1

int maximizeSum(int* nums, int numsSize, int k) {
    int flag = 0;
    int max = 0;
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] > max)
        {
            flag = i;
            max = nums[i];
        }
    }

    max = 0;
    while (k--)
    {
        max += nums[flag];
        nums[flag]++;
    }

    return max;
}